//! GATT API. Generated with `dbus-codegen-rust -s -d org.bluez -c nonblock -m None -p /org/bluez/hci0`.

use std::collections::HashMap;

use dbus;
use dbus::arg;
use dbus::nonblock;

pub trait OrgBluezGattManager1 {
    fn register_application(
        &self,
        application: dbus::Path,
        options: ::std::collections::HashMap<&str, arg::Variant<Box<dyn arg::RefArg>>>,
    ) -> nonblock::MethodReply<()>;
    fn unregister_application(&self, application: dbus::Path) -> nonblock::MethodReply<()>;
}

impl<'a, T: nonblock::NonblockReply, C: ::std::ops::Deref<Target = T>> OrgBluezGattManager1
    for nonblock::Proxy<'a, C>
{
    fn register_application(
        &self,
        application: dbus::Path,
        options: ::std::collections::HashMap<&str, arg::Variant<Box<dyn arg::RefArg>>>,
    ) -> nonblock::MethodReply<()> {
        self.method_call(
            "org.bluez.GattManager1",
            "RegisterApplication",
            (application, options),
        )
    }

    fn unregister_application(&self, application: dbus::Path) -> nonblock::MethodReply<()> {
        self.method_call(
            "org.bluez.GattManager1",
            "UnregisterApplication",
            (application,),
        )
    }
}

pub trait OrgBluezGattService1 {
    fn uuid(&self) -> nonblock::MethodReply<String>;
    fn primary(&self) -> nonblock::MethodReply<bool>;
    fn device(&self) -> nonblock::MethodReply<()>;
    fn includes(&self) -> nonblock::MethodReply<Vec<String>>;
    fn handle(&self) -> nonblock::MethodReply<u16>;
    fn set_handle(&self) -> nonblock::MethodReply<u16>;
}

pub trait OrgBluezGattCharacteristic1 {
    /// Issues a request to read the value of the characteristic and returns
    /// the value if the operation was successful.
    ///
    /// Possible options: "offset": uint16 offset
    ///				  "mtu": Exchanged MTU (Server only)
    ///				  "device": Object Device (Server only)
    fn read_value(
        &self,
        options: HashMap<String, arg::Variant<Box<dyn arg::RefArg>>>,
    ) -> nonblock::MethodReply<Vec<u8>>;

    /// Issues a request to write the value of the characteristic.
    ///
    /// Possible options: "offset": Start offset
    ///				  "type": string
    ///                  Possible values:
    ///              "command": Write without
    ///                  response
    ///                  "request": Write with response
    ///                  "reliable": Reliable Write
    ///                "mtu": Exchanged MTU (Server only)
    ///                "device": Device path (Server only)
    ///                "link": Link type (Server only)
    ///                "prepare-authorize": True if prepare
    ///                             authorization
    ///                             request
    fn write_value(
        &self,
        value: Vec<u8>,
        options: HashMap<String, arg::Variant<Box<dyn arg::RefArg>>>,
    ) -> nonblock::MethodReply<()>;

    /// Acquire file descriptor and MTU for writing
    ///
    /// Possible options: "device": Object Device (Server only)
    ///				  "mtu": Exchanged MTU (Server only)
    ///				  "link": Link type (Server only)
    fn aquire_write(
        &self,
        options: HashMap<String, arg::Variant<Box<dyn arg::RefArg>>>,
    ) -> nonblock::MethodReply<(isize, u16)>;

    /// Acquire file descriptor and MTU for notify.
    ///
    /// Possible options: "device": Object Device (Server only)
    ///				  "mtu": Exchanged MTU (Server only)
    ///				  "link": Link type (Server only)
    fn aquire_notify(
        &self,
        options: HashMap<String, arg::Variant<Box<dyn arg::RefArg>>>,
    ) -> nonblock::MethodReply<(isize, u16)>;

    fn start_notify(&self) -> nonblock::MethodReply<()>;

    fn stop_notify(&self) -> nonblock::MethodReply<()>;

    fn confirm(&self) -> nonblock::MethodReply<()>;

    fn uuid(&self) -> nonblock::MethodReply<String>;

    fn service(&self) -> nonblock::MethodReply<String>;

    fn value(&self) -> nonblock::MethodReply<Vec<u8>>;

    fn write_acquired(&self) -> nonblock::MethodReply<bool>;

    fn notify_acquired(&self) -> nonblock::MethodReply<bool>;

    fn notifying(&self) -> nonblock::MethodReply<bool>;

    fn flags(&self) -> nonblock::MethodReply<Vec<String>>;

    fn handle(&self) -> nonblock::MethodReply<u16>;

    fn set_handle(&self, handle: u16) -> nonblock::MethodReply<()>;
}

pub trait OrgBluezGattDescriptor1 {
    fn read_value(
        &self,
        options: HashMap<String, arg::Variant<Box<dyn arg::RefArg>>>,
    ) -> nonblock::MethodReply<Vec<u8>>;

    fn write_value(
        &self,
        value: Vec<u8>,
        flags: HashMap<String, arg::Variant<Box<dyn arg::RefArg>>>,
    ) -> nonblock::MethodReply<()>;

    fn uuid(&self) -> nonblock::MethodReply<String>;

    fn characteristic(&self) -> nonblock::MethodReply<String>;

    fn value(&self) -> nonblock::MethodReply<Vec<u8>>;

    fn flags(&self) -> nonblock::MethodReply<Vec<String>>;
}

pub trait OrgBluezGattProfile1 {
    fn release();

    fn uuids(&self) -> nonblock::MethodReply<Vec<String>>;
}
